RbacCache   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 19
dl 0
loc 22
rs 10
c 0
b 0
f 0

3 Functions

Rating   Name   Duplication   Size   Complexity  
A get 0 3 1
A set 0 3 1
A del 0 3 1
1
import { Injectable } from '@nestjs/common';
2
import { ICacheRBAC } from '../interfaces/cache.rbac.interface';
3
import * as  NodeCache from 'node-cache';
4
5
@Injectable()
6
export class RbacCache implements ICacheRBAC {
7
    KEY = 'RBAC';
8
    TTL = 0;
9
10
    private readonly cache;
11
12
    constructor() {
13
        this.cache = new NodeCache();
14
    }
15
16
    get(): object | null {
17
        return this.cache.get(this.KEY);
18
    }
19
20
    set(value: object): void {
21
        this.cache.set(this.KEY, value, this.TTL);
22
    }
23
24
    del(): void {
25
        this.cache.del(this.KEY);
26
    }
27
}
28